package com.qiantu.phone.ui.adapter;

import android.content.Context;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.qiantu.api.entity.DeviceShareRecord;
import com.qiantu.phone.R;
import com.qiantu.phone.app.AppAdapter;

/**
 *    author : Android 轮子哥
 *    github : https://github.com/getActivity/AndroidProject
 *    time   : 2019/09/22
 *    desc   : 状态数据列表
 */
public final class DeviceShareRecordAdapter extends AppAdapter<DeviceShareRecord> {

    public DeviceShareRecordAdapter(@NonNull Context context) {
        super(context);
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return new ViewHolder();
    }

    private final class ViewHolder extends AppAdapter<?>.ViewHolder {

        private final ImageView iconShare;
        private final TextView tvDeviceName;
        private final TextView tvShareTime;
        private final TextView btnRecover;

        private ViewHolder() {
            super(R.layout.item_device_share_record);
            iconShare = findViewById(R.id.icon_share);
            tvDeviceName = findViewById(R.id.tv_device_name);
            tvShareTime = findViewById(R.id.tv_share_time);
            btnRecover = findViewById(R.id.btn_recover);
        }

        @Override
        public void onBindView(int position) {
            btnRecover.setEnabled(false);
            if(position == 2){
                btnRecover.setSelected(true);
                btnRecover.setText("124:56:24");
                btnRecover.setEnabled(true);
            }
        }
    }

    @Override
    public long getItemId(int position) {
        return getData().get(position).hashCode();
    }
}